-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Experiment] Ktor Call.Factory #7326
Conversation
import okhttp3.RequestBody | ||
import okhttp3.ResponseBody | ||
|
||
actual suspend fun HttpResponse.toHttpResponseBody(): ResponseBody { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need the most help here. buffer.write(bytes)
below is blocking, so at least that should be sorted out.
|
||
actual suspend fun RequestBody.toHttpRequestBody(): Any { | ||
val buffer = okio.Buffer() | ||
this.writeTo(buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Ktor doc examples aren't great here, using readBytes()
https://ktor.io/docs/request.html#upload_file
And "This function accepts different types of payloads, including plain text, arbitrary class instances, form data, byte arrays, and so on"
Yeah I think ktor is the wrong abstraction. It's a multiplatform API that wraps various engines. We're better off wrapping other engines directly for maximum power and performance. |
My best idea for JS is to never stream the request or response body. |
I like this approach, but I think it's useful here just to validate it possible and provide a template. I can close this PR off once it's the best it can be, but still have something to point people to. I also think it's best if we provide this option, prove it works, but then let others who need this build and maintain the implementation. |
Agreed! |
What would the best API be for JS? Is that a lot of work that we should take advantage of Ktor here? Would this fly as a JS reference implementation? |
# Conflicts: # kotlin-js-store/yarn.lock # okhttp/src/nonJvmMain/kotlin/okhttp3/RequestBody.kt
Probabbly |
Flush out bugs and implementation questions for KMP Call.Factory.
If I remember right, the Plan of Records, it we won't supply this, but it's valid to confirm it's possible.
Found
Limitations
Open Questions